<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<title>Jet Mobile</title>
</head>
<body>
	<script src="libs/jquery-1.8.1.min.js"></script>
	<script>
	$(document).bind("mobileinit", function () {		
		$.mobile.ajaxEnabled = false;
		$.mobile.linkBindingEnabled = false;
		$.mobile.hashListeningEnabled = false;	
		$.mobile.pushStateEnabled = false;
		$.mobile.defaultDialogTransition = 'none';	
		$.mobile.orientationChangeEnabled = true;
		$('div[data-role="page"]').live('pagehide', function (event, ui) {
		    $(event.currentTarget).remove();
		});		
		$(window).bind('create', function () {
			$.mobile.hidePageLoadingMsg();
		});
		$.mobile.activeBtnClass = 'unused';
	});
	</script>
	<script src="js/scripts.min.js"></script>
	<link rel="stylesheet" type="text/css" href="css/style.min.css" />

	<div data-role="page" id="page" data-theme="a">
		<div id="login" style="display: none;"></div>
		<div id="header" data-role="header" style="display: none;">
			<div id="bar"></div>
		</div>	
		<div id="content" data-role="content" style="display: none;"></div>
		<div id="footer" data-role="footer" style="display: none;"></div>
	</div>

	<script>
	(function () {
		var config;
		var url = '../';
		$.ajax({
			url: url + 'index.php?entryPoint=getMobileConfig',
			cache: false,
			async: false,
			dataType: 'json',		
			success: function (resonce) {
				config = resonce;
			},
			error: function () {
				alert("Could not connect to SugarCRM.");
				throw new Error;
			}
		});
		
		if (this.Application.prototype.getBaseUrl(config.sugarUrl) != this.Application.prototype.getBaseUrl(window.location.href)) {	
			config.sugarUrl = this.Application.prototype.getSugarUrl(window.location.href) + "/";
			config.apiUrl = config.sugarUrl + 'service/jetMobile/rest.php';
		}					
		var App = this.App = new this.Application({
			sugarUrl: config.sugarUrl,
			apiUrl: config.apiUrl,
			name: config.name,
			jsCaching: config.jsCaching,
			templateCaching: config.templateCaching
		});		
		$(function () {	
			if (App.getSessionId() != false) {
				App.run();	
			} else {
				App.superView.showLoginForm();
			}
		});				
	}).call(this);
	</script>
</body>
</html>
